{% extends "base.html" %}
  {% block content %}
    {% from "forms/macros.html" import render_field_busqueda %}
    <SCRIPT LANGUAGE="JavaScript">
	
		url = "/tipoItems/modificar/ID/"
		url2 = "/tipoItems/eliminar/ID/"
		url3 = "/tipoItems/consultar/ID/"
		
		id_href = 'modificar'
		id_href2 = 'eliminar'
		id_href3 = 'consultar'
 
		function obtener_id(id) {
        	link = document.getElementById(id_href)
        	link2 = document.getElementById(id_href2)
        	link3 = document.getElementById(id_href3)
        	new_url = url.replace('ID', id)
        	new_url2 = url2.replace('ID', id)
        	new_url3 = url3.replace('ID', id)
        	link.href = new_url
        	link2.href = new_url2
        	link3.href = new_url3
        
		}
		function pregunta(){
    		if(confirm('Esta seguro de que desea eliminar el tipo de item?')){
    			return true;
    		}else{
    			return false;
    		}
    	}
	</SCRIPT>
	<h2> Administración de Tipo de Items </h2>
    <form method="POST" action={{url_for('tipoItems.administracion_tipoItem')}} class="form">
                {{ form.csrf_token }}  
    <div style="overflow:auto; width: 770px; height: 550px;" > 
         <table>
         <tr >
                 <th></th>
                 <th><label>Filtro</label> </th>
                 <th>{{ render_field_busqueda(form.nombre, class="input text") }}</th>
                 <th></th>
        </tr >                         
                <tr >
                    <th></th>
                    <th> <center>ID </center></th>
                    <th><center> NOMBRE </center> </td>
                    <th> <center> FASES <c/enter></td>
        </tr >                 
                {% for tipoItem in tipoItems %}                 
                    <tr >
                          <th><input type = "radio" name = "seleccionado" id="select" onchange="obtener_id({{tipoItem.id}})"></th>
                          <td> <center>{{ tipoItem.id }} </center></td>
		      			  <td> <center>{{ tipoItem.nombre }} <center></td>
		      			  <td> <center>{{ tipoItem.fase.nombre }} <center></td>
		      			  
                    </tr>                  
                {% endfor %}
               
        </table>
       </div>
       </br>
        <div class="buttons">
                <button type="submit" class="button green">
                Buscar
                </button>
                
                <button type="submit" class="button green">
		                <a href="{{ url_for('tipoItems.seleccionar_fase_crear') }}">Crear</a>
		        </button>
		        
		        <button type="submit" class="button green">
               		 <a href="" id="modificar">Modificar</a>
        		</button>
        		
        		<button type="submit" class="button green">
                		<a href="" id="consultar">Consultar</a>
        		</button>
        		
        		<button type="submit"  onclick =  "return pregunta()">
        			<a href="" id="eliminar">Eliminar</a>
        		</button>
        		
        		<button type="submit" class="button green">
		                <a href="{{ url_for('tipoItems.seleccionar_fase') }}">Importar</a>
		        </button>
       
        </div>  
                 
    </form>
   
   
  {% endblock %}
